package com.lcc.lynx.base.system.service.impl;

import com.lcc.lynx.base.system.mapper.SysDictDtlMapper;
import com.lcc.lynx.base.system.pojo.dv.SysDictDtlDV;
import com.lcc.lynx.base.system.service.SysDictDtlService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 字典明细服务实现
 * @auth lcc
 * @date 2025-01-01
 */
@Service
@Transactional
@AllArgsConstructor
public class SysDictDtlServiceImpl implements SysDictDtlService {

    private SysDictDtlMapper mapper;
    

    @Override
    public SysDictDtlMapper getMapper() {
       return mapper;
    }

    @Override
    public int save(List<SysDictDtlDV> list) {
        list.stream().filter(i -> i.getDictDtlId() != null).forEach(this::updateById);
        this.insertList(list.stream().filter(i -> i.getDictDtlId() == null).toList());
        return list.size();
    }
}